<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>threadpool.WorkRequest</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="threadpool-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://chrisarndt.de/projects/threadpool/">Threadpool</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="threadpool-module.html">Module&nbsp;threadpool</a> ::
        Class&nbsp;WorkRequest
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="threadpool.WorkRequest-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class WorkRequest</h1><p class="nomargin-top"><span class="codelink"><a href="threadpool-pysrc.html#WorkRequest">source&nbsp;code</a></span></p>
<p>A request to execute a callable for putting in the request queue later.</p>
<p>See the module function <tt class="rst-docutils literal"><span class="pre">makeRequests</span></tt> for the common case
where you want to build several <tt class="rst-docutils literal"><span class="pre">WorkRequest</span></tt> objects for the same
callable but with different arguments for each call.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="threadpool.WorkRequest-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">callable_</span>,
        <span class="summary-sig-arg">args</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">kwds</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">requestID</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">callback</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">exc_callback</span>=<span class="summary-sig-default">&lt;function _handle_thread_exception at 0x128f0b0&gt;</span>)</span><br />
      Create a work request for a callable and attach callbacks.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="threadpool-pysrc.html#WorkRequest.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__str__"></a><span class="summary-sig-name">__str__</span>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="threadpool-pysrc.html#WorkRequest.__str__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Method Details</span></td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">callable_</span>,
        <span class="sig-arg">args</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">kwds</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">requestID</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">callback</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">exc_callback</span>=<span class="sig-default">&lt;function _handle_thread_exception at 0x128f0b0&gt;</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="threadpool-pysrc.html#WorkRequest.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Create a work request for a callable and attach callbacks.</p>
<p>A work request consists of the a callable to be executed by a
worker thread, a list of positional arguments, a dictionary
of keyword arguments.</p>
<p>A <tt class="rst-docutils literal"><span class="pre">callback</span></tt> function can be specified, that is called when the
results of the request are picked up from the result queue. It must
accept two anonymous arguments, the <tt class="rst-docutils literal"><span class="pre">WorkRequest</span></tt> object and the
results of the callable, in that order. If you want to pass additional
information to the callback, just stick it on the request object.</p>
<p>You can also give custom callback for when an exception occurs with
the <tt class="rst-docutils literal"><span class="pre">exc_callback</span></tt> keyword parameter. It should also accept two
anonymous arguments, the <tt class="rst-docutils literal"><span class="pre">WorkRequest</span></tt> and a tuple with the exception
details as returned by <tt class="rst-docutils literal"><span class="pre">sys.exc_info()</span></tt>. The default implementation
of this callback just prints the exception info via
<tt class="rst-docutils literal"><span class="pre">traceback.print_exception</span></tt>. If you want no exception handler
callback, just pass in <tt class="rst-docutils literal"><span class="pre">None</span></tt>.</p>
<p><tt class="rst-docutils literal"><span class="pre">requestID</span></tt>, if given, must be hashable since it is used by
<tt class="rst-docutils literal"><span class="pre">ThreadPool</span></tt> object to store the results of that work request in a
dictionary. It defaults to the return value of <tt class="rst-docutils literal"><span class="pre">id(self)</span></tt>.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="threadpool-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://chrisarndt.de/projects/threadpool/">Threadpool</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Nov 19 18:43:47 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
